﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Kkc.Application.Specifications
{
    public static class SpecificationExtensions
    {
        public static IQueryable<T> Satisfy<T>(this IQueryable<T> sequence, ISpecification<T> specification)
        {
            if (specification == null)
                throw new ArgumentNullException("specification");

            return sequence.Where(specification.Expression);
        }

        public static IEnumerable<T> Satisfy<T>(this IEnumerable<T> sequence, ISpecification<T> specification)
        {
            if (specification == null)
                throw new ArgumentNullException("specification");

            return sequence.Where(specification.IsSatisfiedBy);
        }
    }
}